import {h} from 'vue'
export const getDictData = (key, value,crudRef) => {
    if(crudRef == undefined){
        return;
    }
    let label = ''
    let dict = crudRef.value.getColumnService().dicts[key];
    if(dict !== undefined && dict.length > 0){
          if(key == 'tags'){
            if(!value){
              return '';
            }
            let str = []
            dict.map(i => {
              for(let index = 0 ; index < value.length ; index++){
                    if (value[index] == i.value) {
                      str.push(h('a-tag',
                                  {class: 'arco-tag arco-tag-size-medium arco-tag-checked',style:'background-color:'+i.data.color+';color:#fff'},
                                  i.label
                                ))
                      str.push(h('br'))
                    }
                  }
            })
            return h('a-space',str)
          }         
          dict.map(i => {
            if(value && (typeof value) == 'object'){
                for(let index = 0 ; index < value.length ; index++){
                  if (value[index] == i.value) {
                    label += i.label + ' '
                  }
                }
            }else{
              if (value == i.value) {
                label = i.label
              }
            }
          })
    }
    return label
  }  
